package com.frank.lzda.dflzhy.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.lzda.dflzhy.domain.LzdaDflzhy;
import com.frank.lzda.dflzhy.service.ILzdaDflzhyService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 党风廉政会议Controller
 * 
 * @author frank
 * @date 2025-04-07
 */
@Controller
@RequestMapping("/lzda/dflzhy")
public class LzdaDflzhyController extends BaseController
{
    private String prefix = "lzda/dflzhy";

    @Autowired
    private ILzdaDflzhyService lzdaDflzhyService;

    @RequiresPermissions("lzda:dflzhy:view")
    @GetMapping()
    public String dflzhy()
    {
        return prefix + "/dflzhy";
    }

    /**
     * 查询党风廉政会议列表
     */
    @RequiresPermissions("lzda:dflzhy:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LzdaDflzhy lzdaDflzhy)
    {
        lzdaDflzhy.setCreateBy(getLoginName());
        startPage();
        List<LzdaDflzhy> list = lzdaDflzhyService.selectLzdaDflzhyList(lzdaDflzhy);
        return getDataTable(list);
    }

    /**
     * 导出党风廉政会议列表
     */
    @RequiresPermissions("lzda:dflzhy:export")
    @Log(title = "党风廉政会议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LzdaDflzhy lzdaDflzhy)
    {
        List<LzdaDflzhy> list = lzdaDflzhyService.selectLzdaDflzhyList(lzdaDflzhy);
        ExcelUtil<LzdaDflzhy> util = new ExcelUtil<LzdaDflzhy>(LzdaDflzhy.class);
        return util.exportExcel(list, "党风廉政会议数据");
    }

    /**
     * 新增党风廉政会议
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存党风廉政会议
     */
    @RequiresPermissions("lzda:dflzhy:add")
    @Log(title = "党风廉政会议", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LzdaDflzhy lzdaDflzhy)
    {
        lzdaDflzhy.setCreateBy(getLoginName());
        return toAjax(lzdaDflzhyService.insertLzdaDflzhy(lzdaDflzhy));
    }

    /**
     * 修改党风廉政会议
     */
    @RequiresPermissions("lzda:dflzhy:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        LzdaDflzhy lzdaDflzhy = lzdaDflzhyService.selectLzdaDflzhyById(id);
        mmap.put("lzdaDflzhy", lzdaDflzhy);
        return prefix + "/edit";
    }

    /**
     * 修改保存党风廉政会议
     */
    @RequiresPermissions("lzda:dflzhy:edit")
    @Log(title = "党风廉政会议", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LzdaDflzhy lzdaDflzhy)
    {
        lzdaDflzhy.setUpdateBy(getLoginName());
        return toAjax(lzdaDflzhyService.updateLzdaDflzhy(lzdaDflzhy));
    }

    /**
     * 删除党风廉政会议
     */
    @RequiresPermissions("lzda:dflzhy:remove")
    @Log(title = "党风廉政会议", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(lzdaDflzhyService.deleteLzdaDflzhyByIds(ids));
    }
}
